//package com.snu.liwei.lyl_api.service;
//
//import com.snu.liwei.lyl_api.mapper.MyInfoMapper;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.security.core.GrantedAuthority;
//import org.springframework.security.core.authority.AuthorityUtils;
//import org.springframework.security.core.userdetails.User;
//import org.springframework.security.core.userdetails.UserDetails;
//import org.springframework.security.core.userdetails.UserDetailsService;
//import org.springframework.security.core.userdetails.UsernameNotFoundException;
//import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
//import org.springframework.stereotype.Service;
//
//import java.util.List;
//
//@Service
//public class MyUserDetailsService implements UserDetailsService {
//    @Autowired
//    MyInfoMapper myInfoMapper;
//    @Override
//    public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
//        com.snu.liwei.lyl_api.entity.User sysUser;
//        if (!(myInfoMapper.getUser(s).get(0)==null))
//        sysUser=myInfoMapper.getUser(s).get(0);
//        else throw new UsernameNotFoundException("用户名不存在");
//        List<GrantedAuthority> grantedAuthorityList= AuthorityUtils.createAuthorityList("admin");
//        return new User(sysUser.getUsername(),new BCryptPasswordEncoder().encode(sysUser.getPassword()),grantedAuthorityList);
//    }
//}
